package addon.w3.mdx.com;

import java.io.IOException;

import addon.w3.mdx.MDXCOM;
import addon.w3.mdx.LEDataInputStream;
import addon.w3.mdx.MDXException;

/**
struct {
		long	Frame;
		float	a, b, c, d;
		if (LineType > 1) {
			float	InTana, InTanb, InTanc, InTand;
			float	OutTana, OutTanb, OutTanc, OutTand;
		}
	} rotation[nunks];
 * @author madjk
 *
 */
public class MDXRotationCOM extends MDXCOM {
	String tag;
	public int frame = -1;
	public float a,b,c,d;
	public float inTan[];
	public float outTan[];
	
	int parentLineType = -1;
	
	public MDXRotationCOM(String str,int lineType) {
		this.tag = str;
		parentLineType = lineType;
	}
	
	public String getTag() {
		return tag;
	}
	
	public void _decode(LEDataInputStream ins) throws IOException, MDXException {
		frame = ins.readInt();
		a = ins.readFloat();
		b = ins.readFloat();
		c = ins.readFloat();
		d = ins.readFloat();
		if(parentLineType > 1) {
			inTan = new float[4];
			outTan = new float[4];
			for(int i=0;i<inTan.length;i++) inTan[i] = ins.readFloat();
			for(int i=0;i<outTan.length;i++) outTan[i] = ins.readFloat();
		}
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("TAG : "+getTag());
		sb.append("\n\tFRAME : "+frame);
		sb.append("\n\tABCD : "+a+" : "+b+" : "+c+" : "+d);
		if(parentLineType > 1) {
			sb.append("\n\tINTAN[] : "+inTan[0]+" : "+inTan[1]+" : "+inTan[2]+" : "+inTan[3]);
			sb.append("\n\tOUTTAN[] : "+outTan[0]+" : "+outTan[1]+" : "+outTan[2]+" : "+outTan[3]);
		}
		return sb.toString();
	}

	@Override
	public boolean isImplicitTag() {
		// TODO Auto-generated method stub
		return false;
	}
}